package com.xinghai.system.mapper;

import java.util.List;
import java.util.Map;

import com.xinghai.system.domain.QdPay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 对账单Mapper接口
 *
 * @author xinghai
 * @date 2024-12-04
 */
public interface QdPayMapper  extends BaseMapper<QdPay>
{

    @Select("select a.name pushName,a.amount todaySellData,b.amount todayBuyData from " +
            "(select sum(amount) amount,seller_user_name name,seller_user_id user_id " +
            "from qd_pay where DATE_FORMAT(create_time,\"%Y-%m-%d\") = #{date} " +
            "and seller_user_id in (select id from qd_user where super_id = #{loginId}) GROUP BY name,user_id) a  " +
            "LEFT JOIN (select sum(amount) amount,buyer_user_name name,buyer_user_id user_id from qd_pay " +
            "where DATE_FORMAT(create_time,\"%Y-%m-%d\") = #{date} and " +
            "buyer_user_id in (select id from qd_user where super_id = #{loginId})  GROUP BY name,user_id) b on a.user_id = b.user_id")
    List<Map<String, Object>> pushListInfo(@Param("date") String date,@Param("loginId") String loginId);
}
